package com.wc.alorithm_blue_bridge._动态规划.地宫取宝;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2025/4/7 15:05
 * @description
 * https://www.lanqiao.cn/problems/216/learning/?page=1&first_category_id=1&tags=DFS&tag_relation=union
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 55, M = 55, K = 15, L = 15, P = (int)1e9 + 7;
    // f[i][j][l][k] 表示到达 i, j 点 最大值为 l, 拿的次数为 k 的方案数
    static long[][][][] f = new long[N][M][L][K];
    static int[][] g = new int[N][N];
    static int n, m, k;
    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        k = sc.nextInt();
        // 初始化第一行都不能走, (1, 1) 只能从 (0, 1) 的地方走, 这里是我自己的习惯
        Arrays.fill(g[0], P);

        for (int i = 1; i <= n; i++) {
            // 这里g[i][j] + 1 是保证 val > 0的, 方便后续操作
            for (int j = 1; j <= m; j++) g[i][j] = sc.nextInt() + 1;
        }

        // 初始化 0, 1 位置 maxv = 0, cnt = 0
        f[0][1][0][0] = 1;

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                // t 表示到达 i, j 取了的次数
                for (int t = 0; t <= k; t++) {
                    // tt 表示目前的值
                    int tt = g[i][j];

                    // hh 表示以前取了的可能的最大值
                    for (int hh = 0; hh < K; hh++) {
                        // 从上边走过来
                        // hh < tt, 表示当前值比之前的值大, 更新f[i][j][tt][t]
                        if (t > 0 && hh < tt) f[i][j][tt][t] = (f[i][j][tt][t] + f[i - 1][j][hh][t - 1]) % P;
                        // 不取当前值, 沿用之前的值, 更新f[i][j][hh][t]
                        f[i][j][hh][t] = (f[i][j][hh][t] + f[i - 1][j][hh][t]) % P;

                        // 从左边走过来, 与上面同理
                        if (t > 0 && hh < tt) f[i][j][tt][t] = (f[i][j][tt][t] + f[i][j - 1][hh][t - 1]) % P;
                        f[i][j][hh][t] = (f[i][j][hh][t] + f[i][j - 1][hh][t]) % P;
                    }
                }
            }
        }
        long res = 0;
        // 计算答案, 计算f[n][m][max][k], 也就是到达 (n, m) 最大值为max, 一共取了 k次的方案数的和
        for (int i = 1; i < K; i++) {
            res = (res + f[n][m][i][k]) % P;
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}

